package com.hydl.power;

import com.hydl.power.mqtt.Client;
import com.hydl.power.netty.server.NettyServer;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableSwagger2
@MapperScan("com.hydl.power.mapper")
public class PowermaintenanceApplication {
    private static final Logger log = LoggerFactory.getLogger(PowermaintenanceApplication.class);
    public static void main(String[] args) {
        SpringApplication.run(PowermaintenanceApplication.class, args);
        run();
    }

    private static NettyServer nettyServer = new NettyServer();
    private static Client MqttClient = new Client();

    private static void run() {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                nettyServer.run();
            }
        });
        Thread mqthread = new Thread(new Runnable() {
            @Override
            public void run() {
                MqttClient.start();
            }
        });
        thread.start();
        mqthread.start();

    }
}
